<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.io.*"%>
<%@ page import="requestInterFace.Handle.userHandle"%>
<%@ page import="xml.response.*"%>
<%@ page import="xml.root"%>
<%@ page import="util.print.printLogCat"%>
<%@ page import="org.sql.table.*"%>
<%@ page import="xml.var"%>
<%@ page import="java.util.Vector"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="requestInterFace.UserInfoInterFace.*"%>
<%@ page import="org.json.jsonNode"%>
<%@ page import="jqgrid.jqgrid"%>
<%@ include file="../../util/paramPrint.jsp" %>
<%@ page trimDirectiveWhitespaces="true" %> 
<%   

    /*********** jqgrid ******************/
		jqgrid jq=new jqgrid();
		jq.setRows(request.getParameter(jqgrid._rows));
		jq.setSord(request.getParameter(jqgrid._sord));
		jq.setSortname(request.getParameter(jqgrid._sortname));
		jq.setPage(request.getParameter(jqgrid._page));
		jq.setOper(request.getParameter(jqgrid._oper));
		jq.setSearch(request.getParameter(jqgrid._search));
		/*************************************/
		
		
String User_ID = request.getParameter("User_ID");
String name = request.getParameter("User_Name");
String User_type =request.getParameter("User_Type");
String UP_ID =request.getParameter("UP_ID");//业务员ID
String start_call_time =request.getParameter("start_call_time");//开始访问时间
String end_call_time =request.getParameter("end_call_time");//开始访问时间
String userType=(String)session.getAttribute("User_Type");
String userID=(String)session.getAttribute("User_ID");
		userinfo1_1 user=new userinfo1_1();
		user.setLimit((jq.getPageInt()-1)*jq.getRowsInt(), jq.getRowsInt());
		user.setResultField("User_ID").setResultField("User_Name").setResultField("User_Type").
		setResultField("UP_ID").setResultField("Called_Time").
		setResultField("Addr").setResultField("TEL").setResultField("TEL");
		
		
		if(userType!=null&&userType.equals("1")){
			//管理员
		if(User_ID!=null&&(!User_ID.equals(""))){
		 user.addequwhile("User_ID"," like ","%"+ java.net.URLDecoder.decode(User_ID,"UTF-8")+"%");
		}
		
		if(UP_ID!=null&&(!UP_ID.equals(""))){
		 user.addequwhile("UP_ID"," = ",UP_ID);
		}
		
		}else if(userType!=null&&userType.equals("2")){
			//业务员
			if(User_ID!=null&&(!User_ID.equals(""))){
		 user.addequwhile("User_ID"," like ","%"+ java.net.URLDecoder.decode(User_ID,"UTF-8")+"%");
			}
		 user.addequwhile("UP_ID"," = ",userID);
		}else if(userType!=null&&userType.equals("3")){
			//客户
			user.addequwhile("User_ID"," = ",userID);
		}else if(userType!=null&&userType.equals("4")){
			//送货员

		return ;
		}else{

		return ;
		}
		
		
		if(name!=null&&(!java.net.URLDecoder.decode(name,"UTF-8").equals(""))&&(java.net.URLDecoder.decode(name,"UTF-8").length()>1)){
		 user.addequwhile("User_Name"," like ","%"+ java.net.URLDecoder.decode(name,"UTF-8")+"%");
		}
		if(User_type!=null&&(!User_type.equals(""))&&(!User_type.equals("0"))){
		 user.addequwhile("User_type"," = ",User_type);
		}

		if(start_call_time!=null&&(!start_call_time.equals(""))){
		  user.addequwhile("Called_Time"," >=",start_call_time);
		}
		if(end_call_time!=null&&(!end_call_time.equals(""))){
		 user.addequwhile("Called_Time"," <=",end_call_time);
		}
		Vector d=user.getTableFactroy();
	
		jsonNode json=new jsonNode(2);
		for(int i=0;i<d.size();i++){
			userinfo1_1 u=(userinfo1_1)d.elementAt(i);
			Enumeration e=u.getTable().elements();
         jsonNode us=new jsonNode(1);
		 int y=0;
		 for(int j=0;j<u.getResultFieldNum();j++){
			String field=(String)u.getSql().getResultField().elementAt(j);
    		var v=(var)u.getTable().get(field);
    					jsonNode node;
			if(v.getName().equals("User_ID")){
			node=new jsonNode(0,"value",v.getValue());
			}else{
			node=new jsonNode(0,v.getName(),v.getValue());
			}
			us.putNode(""+y, node);
			y++;
		}

		jsonNode nodeid=new jsonNode(0,"id",""+i);
		us.putNode(""+y, nodeid);
		json.putNode(""+i, us);
		}
		//printLogCat.printlnWriter(root.getXmlString());
		String rep=json.getJsonText();
%>
<%=rep%>
